//度转度°分′秒″
/**
 * 
 * @param {*} val 坐标字符串
 * @param {*} lon 经度或者纬度，分别用'lon'/'lat'表示
 * @returns 
 */
export default function ToDegrees(val, lon) {
    if (typeof val == "undefined" || val == "") {
        return "";
    }
    var i = val.indexOf(".");
    var strDu = i < 0 ? val : val.substring(0, i); //获取度
    var strFen = 0;
    var strMiao = 0;
    if (i > 0) {
        var strFen = "0" + val.substring(i);
        strFen = strFen * 60 + "";
        i = strFen.indexOf(".");
        if (i > 0) {
            strMiao = "0" + strFen.substring(i);
            strFen = strFen.substring(0, i); //获取分
            strMiao = strMiao * 60 + "";
            i = strMiao.indexOf(".");
            strMiao = strMiao.substring(0, i + 4); //取到小数点后面三位
            strMiao = parseFloat(strMiao).toFixed(2); //精确小数点后面两位
        }
    }
    let lo, la;
    if (lon == "lon") {
        if (val >= 0) {
            lo = "E";
        } else {
            lo = "W";
        }
        return strDu + "°" + strFen + "′" + strMiao + "″" + lo;
    } else if (lon == "lat") {
        if (val >= 0) {
            la = "N";
        } else {
            la = "S";
        }
        return strDu + "°" + strFen + "′" + strMiao + "″" + la;
    }

    // 经纬度表示法是：strDu°  strFen′ strMiao″，
}
